package org.csu.jpetstore_cms.mapper;


import org.apache.ibatis.annotations.*;
import org.csu.jpetstore_cms.pojo.Account;

import java.util.List;

@Mapper
public interface AccountMapper {

    @Select("SELECT * FROM account")
    List<Account> findAll();

    @Select("SELECT * FROM account WHERE userid=#{id}")
    Account findByID(String id);

    @Update("UPDATE account SET " +
            "email=#{email},firstname=#{firstname},lastname=#{lastname},status=#{status},addr1=#{addr1},addr2=#{addr2},city=#{city},state=#{state},zip=#{zip},country=#{country},phone=#{phone} " +
            "WHERE userid=#{userid}")
    void updateAccountInfo(Account account);

    @Insert("INSERT INTO account(userid,email,firstname,lastname,status,addr1,addr2,city,state,zip,country,phone)" +
            "values (#{userid},#{email},#{firstname},#{lastname},#{status},#{addr1},#{addr2},#{city},#{state},#{zip},#{country},#{phone})")
    void insertAccount(Account account);

    @Select("SELECT * FROM account LIMIT #{pageNum}, #{pageSize}")
    List<Account> findByPage( Integer pageNum,  Integer pageSize);


}
